$(function () {
    //下面是代码的抽取操作
    var permissionDatagrid,editAndQuitBtn,permissionDialog,editForm;
    permissionDatagrid = $('#permission_datagrid');
    editForm = $('#editForm');
    permissionDatagrid.datagrid({
        url:'/permission/list.do',
        fit:true,
        fitColumns:true,
        pagination:true,
        pageNumber:1,
        pageSize:10,
        toolbar:"#tb",
        singleSelect:true,
        rownumbers:true,
        columns:[[
            {field:'id',title:'编号',width:100,align:"center"},
            {field:'name',title:'名称',width:100,align:"center"},
            {field:'resource',title:'资源名称',width:100,align:"center"}
        ]]
    });
    var comdObj = {
        reload:function () {
            $.messager.confirm("温馨提示:","亲,确定要重新加载权限吗?",function (flag) {
                if(flag){
                    $.get("/permission/reload.do",function (data) {
                        if (data.success){
                            $.messager.confirm("温馨提示:",data.msg,"info",function (){
                                permissionDatagrid.datagrid("reload");
                            })
                        }
                    })
                }
            })
        }
    }
    $("a[data-cmd]").click(function () {
        var op = $(this).data("cmd");
        comdObj[op]();
    });
});
